--[[ 编码: JX-24-18 名称: 拣料箱绑定界面-拣料箱号输入 作者:HAN 日期:2025-1-29 级别:固定 (说明本段代码在项目中不太会变化) 函数: AfterPickingBoxCodeInput 功能: -- 根据输入的条码到【容器】找到类型= 拣料箱 的容器 更改记录: V2.0 HAN 2025-2-9 -- 增加对绑定拣料箱编码的盘点,是否已经在本次绑定操作中绑定过,避免重复绑定 --]] wms_cntr= require( "wms_container" ) function AfterPickingBoxCodeInput ( strLuaDEID ) local nRet, strRetInfo, msg -- 获取输入的拣料箱编码 nRet, strRetInfo = mobox.getCurEditDataObjAttr( strLuaDEID, "Input", "PickingBoxCode", "Station", "PickingBoxNum" ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取当前编辑属性失败! "..strRetInfo ) end local obj_attrs = json.decode( strRetInfo ) local input_code = lua.Get_StrAttrValue( obj_attrs[1].value ) local picking_box_codes = lua.Get_StrAttrValue( obj_attrs[2].value ) local station = lua.Get_StrAttrValue( obj_attrs[3].value ) local picking_box_num = lua.Get_NumAttrValue( obj_attrs[4].value ) if ( input_code == '' ) then return end -- 通过拣料箱编码去判断【容器】是否存在,是否是拣料箱,是否已经有货位绑定 local cntr_obj nRet, cntr_obj = wms_cntr.GetInfo( strLuaDEID, input_code ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "获取容器对象失败! "..cntr_obj ) end if ( cntr_obj == '' ) then mobox.setInfo( strLuaDEID, "编码 = '"..input_code.."'的拣料箱不存在!") return end -- 判断料箱的类型是否=4(拣料箱) if ( cntr_obj.type ~= 4 ) then mobox.stopProgram( strLuaDEID, "编码 = '"..input_code.."'的容器不是拣料箱!") return end -- 判断料箱是否已经有绑定 if ( cntr_obj.position ~= '' ) then mobox.stopProgram( strLuaDEID, "编码 = '"..input_code.."'的拣料箱已经和站台'"..cntr_obj.position.."'绑定") return end if (picking_box_codes ~= '') then -- 判断一下绑定的拣料箱数量不能超过计划数量 local seg = lua.split( picking_box_codes, ";" ) if ( #seg >= picking_box_num ) then mobox.setInfo( strLuaDEID, "绑定的拣货箱数量已经达到要求,不能继续绑定拣料箱!") return end -- V2.0 判断一下在本次绑定中是否已经绑定 local seg_code = lua.split( picking_box_codes, ";" ) local n for n = 1, #seg_code do if ( seg_code[n] == input_code ) then mobox.setInfo( strLuaDEID, "绑定的拣货箱'"..input_code.."'已经绑定,不能再次绑定!") return end end picking_box_codes = picking_box_codes..";" end picking_box_codes = picking_box_codes..input_code local action = { { action_type = "set_dlg_attr", value = { { attr = "PickingBoxCode", value = picking_box_codes }, { attr = "Input", value = "" } } } } nRet, strRetInfo = mobox.setAction( strLuaDEID, lua.table2str(action) ) if ( nRet ~= 0 ) then lua.Error( strLuaDEID, debug.getinfo(1), "setAction失败! "..strRetInfo ) end end